for _ in range(int(input())):
s=input()
a=0
b=0
for i in range(len(s)):
if i%2==0:
a=a*10+int(s[i])
else:
b=b*10+int(s[i])
print((a+1)*(b+1)-2)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
#ifndef ONLINE_JUDGE
// For getting input from input.txt file
freopen("input.txt", "r", stdin);
// Printing the Output to output.txt file
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int t; cin>>t;
// cout<<t<<endl;
while(t--)
{
string n;
cin>>n;
string a,b;
// cin>>a>>b;
for (int i = n.size()-1; i>=0; --i)
{
if((n.size()-i)%2)
{
a.push_back(n[i]);
}
else b.push_back(n[i]);
/* code */
}
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
int i=0;
while(a[i]=='0' && i<a.size())
{
i++;
}
int j=0;
while(b[j]=='0' && j<b.size())
{
j++;
}
string aa,bb;
for (int k = i; k <a.size() ; ++k)
{
aa.push_back(a[k]);
/* code */
}
for (int k = j; k <b.size() ; ++k)
{
bb.push_back(b[k]);
/* code */
}
// cout<<aa<<" "<<bb<<endl;
stringstream geek(aa);
int x=0;
geek>>x;
stringstream geeks(bb);
int y=0;
geeks>>y;
// if(x%10==0)
// {
// x--;
// }
// // if(y%10==0 || y<10)
// // {
// // // y--;
// // }
// if((aa.size()+bb.size())%2==1)cout<<(x+1)*(y)<<endl;
// else cout<<(x)*(y+1)<<endl;
cout<<(x+1)*(y+1)-2<<endl;
}
return 0;
}
1475E - Advertising Agency | 1345B - Card Constructions |
1077B - Disturbed People | 653A - Bear and Three Balls |
794A - Bank Robbery | 157A - Game Outcome |
3B - Lorry | 1392A - Omkar and Password |
489A - SwapSort | 932A - Palindromic Supersequence |
433A - Kitahara Haruki's Gift | 672A - Summer Camp |
1277A - Happy Birthday Polycarp | 577A - Multiplication Table |
817C - Really Big Numbers | 1355A - Sequence with Digits |
977B - Two-gram | 993A - Two Squares |
1659D - Reverse Sort Sum | 1659A - Red Versus Blue |
1659B - Bit Flipping | 1480B - The Great Hero |
1519B - The Cake Is a Lie | 1659C - Line Empire |
515A - Drazil and Date | 1084B - Kvass and the Fair Nut |
1101A - Minimum Integer | 985D - Sand Fortress |
1279A - New Year Garland | 1279B - Verse For Santa |